package com.forestar.mapControl.utils.tile;

/**
 * 瓦片行列号的起止范围（行，列）
 *
 * @author liubo
 */
public class TilesIndexBound
  {
    public int level;
    public int minTileX;
    public int maxTileX;
    public int minTileY;
    public int maxTileY;

    public boolean isEmpty()
      {
        return minTileX == -1 || maxTileX == -1 || minTileY == -1 || maxTileY == -1;
      }

    public TilesIndexBound(int level, int minTileX, int maxTileX, int minTileY, int maxTileY)
      {
        this.level = level;
        this.minTileX = minTileX;
        this.maxTileX = maxTileX;
        this.minTileY = minTileY;
        this.maxTileY = maxTileY;
      }

    public long getTileCount()
      {
        return getWidth() * getHeight();
      }

    @Override
    public String toString()
      {
        return "[" + minTileX + "," + maxTileX + "],[" + minTileY + "," + maxTileY + "]" + "瓦片总数:" + getTileCount();
      }

    public int getWidth()
      {
        return maxTileX - minTileX + 1;
      }

    public int getHeight()
      {
        return maxTileY - minTileY + 1;
      }

    public TilesIndexBound clone()
      {
        return new TilesIndexBound(level,minTileX,maxTileX,minTileY,maxTileY);
      }
  }
